<template>
	<!--pages/user-center/my-account/my-account.wxml-->
	<page>
		<view v-if="systemInfo==1">


			<view class='top-container dp-flex-col-x-center'>
				<view class='total-money flex-1'>
					{{totalMoney}}元
				</view>
				<view class='other-money dp-flex flex-1'>
					<view class='flex-1 dp-flex-col-xy-center border-right'>
						<text class='money-text'>诚信金</text>
						<text class='money-number'>{{userInfo.deposit_money}}元</text>
					</view>
					<view class='flex-1 dp-flex-col-xy-center border-right'>
						<text class='money-text'>待提现金额</text>
						<text class='money-number'>{{userInfo.frozen_money}}元</text>
					</view>
					<view class='flex-1 dp-flex-col-xy-center border-right no-right'>
						<text class='money-text'>可用余额</text>
						<text class='money-number'>{{userInfo.money}}元</text>
					</view>
				</view>
			</view>
			<view class='bottom-container'>
				<view class='weui-cells' style="margin-top:0;">
					<navigator url="money-in/money-in" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
						<view class="weui-cell__hd dp-flex-xy-center">
							<image class="icon-cell" src="/static/images/user-center/my-account/in.png"></image>
						</view>
						<view class="weui-cell__bd">转入</view>
						<view class="weui-cell__ft weui-cell__ft_in-access"></view>
					</navigator>
					<navigator url="money-out/money-out" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
						<view class="weui-cell__hd dp-flex-xy-center">
							<image class="icon-cell" src="/static/images/user-center/my-account/out.png"></image>
						</view>
						<view class="weui-cell__bd">转出</view>
						<view class="weui-cell__ft weui-cell__ft_in-access"></view>
					</navigator>
					<navigator url="money-detail/money-detail" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
						<view class="weui-cell__hd dp-flex-xy-center">
							<image class="icon-cell" src="/static/images/user-center/my-account/detail.png"></image>
						</view>
						<view class="weui-cell__bd">明细查询</view>
						<view class="weui-cell__ft weui-cell__ft_in-access"></view>
					</navigator>
				</view>
				<view class='bottom-tips dp-flex-col'>
					<view class='bot-tips-item'>
						<text class='red-color'>诚信金：</text>
						诚信金内有余额，表示您的订单还没到期，到期后会自动退回到您的余额。
					</view>
					<view class='bot-tips-item'>
						<text class='red-color'>待提现金额：</text>
						您的提现申请已成功提交，请联系客服（微信<text selectable='true'>13007421866</text>）审核。为确保您的资金安全，需要平台审核，审核后1-3个工作日到账。
					</view>
					<view class='bot-tips-item'>
						<text class='red-color'>可用余额：</text>
						您可以提现，也可以放在此处备用。建议留有余额便于快速发单，或者及时快速抢单。
					</view>
				</view>
			</view>

		</view>

		<view v-else-if="systemInfo==2">
			<view class='ios-top-title'>您的设备暂不支持此服务!</view>
		</view>
	</page>
</template>

<script>
	import app from '@/App.vue';
	import event from '@/utils/event.js';
	import {
		GYZJMODEL as gyzjModel
	} from '@/utils/gyzjModel.js'
	export default {
		onLoad: function(options) {
			var that = this;
			uni.getSystemInfo({
				success: function(res) {
					if (res.platform == "devtools" || res.platform == "android") {
						console.log('android');
						that.systemInfo = 1;
						event.on('afterMoneyChange', that, that.afterMoneyChange);
						var arr = that.main_getGlobal();
						that.getUserInfo(arr.token, arr.type);
					} else if (res.platform == "ios") {
						console.log('ios');
						that.systemInfo = 2;
					}
				}
			})
		},
		methods: {
			// 获取个人信息
			getUserInfo: function(token, type) {
				let that = this;
				gyzjModel.prototype.getUserInfo(token, type).then(data => {
					console.log('data的值', data);
					switch (data.code) {
						case 1:
							let userInfo = data.data.user;
							  console.log('usermoney', userInfo.money);
							            console.log('deposit_money', userInfo.deposit_money);
							            console.log('frozen_money', userInfo.frozen_money);
							let totalMoney = parseFloat(userInfo.money) + parseFloat(userInfo.deposit_money) + parseFloat(userInfo.frozen_money);
							totalMoney.toFixed(2);
							console.log('totalMoney',totalMoney);
							if (totalMoney == 0) {
								totalMoney = '0.00';
							}
							that.userInfo=userInfo;
							that.totalMoney=totalMoney;
							uni.hideLoading();
							break;
						default:
							uni.showToast({
								title: data.message,
								icon: 'none'
							})
							break;
					}
				})
			},
			/*后面的执行*/
			afterMoneyChange: function () {
				var arr = that.main_getGlobal();
			    this.getUserInfo(arr.token,arr.type);
			  },
		},
		data() {
			return {
				userInfo: {},
				needFresh: false,
				systemInfo: 1,
				totalMoney:''
				
			}
		}
	}
</script>

<style>
	@import url("../../../static/style/app.css");

	.top-container {
		height: 30vh;
		/* background-color: #F94C48; */
		background-color: #333;
		color: #fff;
	}

	.total-money {
		font-size: 30px;
		height: 15vh;
		line-height: 15vh;
		text-align: center;
	}

	.money-text {
		opacity: 0.8;
	}

	.money-number {
		font-size: 20px;
	}

	.border-right {
		margin: 5vh 0;
		border-right: 0.5px solid #e5e5e5;
	}

	.btn-pay-wrap {
		margin: 10px 15px;
	}

	.btn-pay {
		background-color: #f94c48;
		color: #fff;
		border-radius: 5px;
	}

	.tips {
		margin: 10px 15px;
		color: #666;
		font-size: 12px;
	}

	.no-right {
		border-right: 0px;
	}

	.bottom-tips {
		padding: 10px 15px;
		font-size: 28upx;
	}

	.bot-tips-item {
		margin-bottom: 10upx;
	}

	.bot-tips-item:last-of-type {
		margin-bottom: 0;
	}

	/*ios样式的判断*/
	.ios-top-title {
		font-size: 18px;
		font-weight: 600;
		padding: 20upx 30upx;
		background-color: #fff;
		text-align: center;
	}
</style>
